<template>
  <div class="index">
    <div class="main">
      <el-container>
        <el-aside style="width: auto">
          <div class="logo" v-if="!isCollapse">
            <h1>{{ userInfo == 0 ? "管理员" : userInfo.account }}</h1>
          </div>
          <div class="logo" v-else>
            <el-avatar
              src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
            ></el-avatar>
          </div>
          <menu-list :list="List" :isCollapse="isCollapse"></menu-list>
        </el-aside>
        <el-container>
          <el-header>
            <i class="el-icon-menu" @click="isCollapse = !isCollapse"></i>
            <span class="out" @click="out">退出登陆</span>
          </el-header>
          <router-view></router-view>
        </el-container>
      </el-container>
    </div>
  </div>
</template>

<script>
import NavMenu from "../router/defaultRouter";
// @ is an alias to /src
import MenuList from "@/components/menu-list.vue";
import { mapState } from "vuex";
import { remSession } from "../utils/common";
export default {
  name: "mains",
  components: {
    MenuList,
  },
  computed: {
    ...mapState(["allRouter", "userInfo"]),
  },
  data() {
    return {
      isCollapse: false,
      List: [],
      // List: this.allRouter[0].children,
    };
  },
  mounted() {
    // this.renderMenu(NavMenu)
    console.log(this.allRouter, "sss");
    this.List = this.allRouter[0].children;
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    async out() {
      sessionStorage.clear();
      // await remSession([
      //   "user-routers",
      //   "user-schoolId",
      //   "user-info",
      //   "user-allRouter",
      //   "schoolId"
      // ]);
      window.location.reload();
    },
  },
};
</script>
<style scoped>
.out{
  cursor:pointer;
}
</style>
